package com.controller.user;

import com.service.user.OtherService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 一些其他请求的控制器，现阶段只包括获取标签和类别
 *
 * 
 */
@RestController
@CrossOrigin
public class OtherController {
  @Autowired OtherService otherService;

  /**
   * 获取所有标签
   *
   * @return 标签列表 TODO 标签
   */
  @GetMapping("getAllLabels")
  public Map<String, String> getAllLabels() {
    List labels = otherService.getAllLabels();
    Map<String, String> map = new HashMap<String, String>();
    map.put("message", "没有标签");
    return map;
  }

  /**
   * 获取所有类别
   *
   * @return 类别列表，每个类别表示为{id: ,name: , subList: }
   */
  @GetMapping("getAllCategories")
  public List<Map<String, Object>> getAllCategories() {
    return otherService.getAllTypes();
  }

  @RequestMapping("feedback")
  public String feedback(
      @RequestParam("userId") String userId,
      @RequestParam("title") String title,
      @RequestParam("content") String content,
      MultipartFile pic1,
      MultipartFile pic2,
      MultipartFile pic3) {
    int ret = otherService.feedback(userId, title, content, pic1, pic2, pic3);
    return String.valueOf(ret);
  }

}
